#

| Chapter 11 The Awk Scripting Language |

## getline

    getline [var] [<file]
            or
    command | getline [var]

Read next line of input. Original awk does not support the syntax to open multiple input streams. The first form reads input from `file` and the second form reads the output of `command`. Both forms read one line at a time, and each time the statement is executed it gets the next line of input. The line of input is assigned to $0 and it is parsed into fields, setting NF, NR and FNR. If `var` is specified, the result is assigned to `var` and the $0 is not changed. Thus, if the result is assigned to a variable, the current line does not change. It is actually a function and it returns 1 if it reads a record successfully, 0 if end-of-line is encountered, and -1 if for some reason it is otherwise unsuccessful. {N}

Reference: function |  | Reference: gsub